package com.wuliu.driver.service;

import com.wuliu.driver.mapper.DriveMapper;
import com.wuliu.driver.pojo.Drive;
import com.wuliu.driver.util.Code;
import com.wuliu.driver.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DriveServiceImpl implements DriveService{
    @Autowired
    private DriveMapper driveMapper;
    @Override
    public Result ins(Drive drive) {
        Integer select = driveMapper.select(drive.getDid());
        if (select != null){
            int i = driveMapper.updStatus(drive.getDid());
            if (i>0){
                return new Result(Code.GET_OK,"添加成功");
            }
            return new Result(Code.GET_ERR,"添加失败");
        }else {
            int ins = driveMapper.ins(drive);
            if (ins>0){
                return new Result(Code.GET_OK,"添加成功");
            }
            return new Result(Code.GET_ERR,"添加失败");
        }

    }
}
